package platform.user.auth.token;

import org.springframework.security.authentication.AbstractAuthenticationToken;

/**
 * 登陆认证所需令牌
 *
 * @author roamer
 * @version V1.0
 * @date 2019-03-10 15:35
 */
public class LoginAuthenticationToken extends AbstractAuthenticationToken {

    private String username;

    private SessionToken token;

    public LoginAuthenticationToken(
            String username, SessionToken token) {
        super(null);
        this.username = username;
        this.token = token;
        setAuthenticated(true);
    }

    @Override
    public Object getCredentials() {
        return token.getValue();
    }

    @Override
    public Object getPrincipal() {
        return username;
    }

    public SessionToken getToken() {
        return token;
    }
}
